package com.bean.serializabletest.model;

import java.awt.*;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * messageBuilder
 */
public class NettyMessageBuilder {
    public static NettyMessage build() {
        NettyMessage nettyMessage = new NettyMessage();
        Header header = new Header();
        RpcRequest request = new RpcRequest();
        header.setCrcCode(1234);
        header.setType(TrayIcon.MessageType.INFO);
        header.setLength(1234);
        header.setSessionId(2001);

        Map<String, Object> map = new LinkedHashMap<>();
        map.put("extraKey", "aga+21_25&");
        header.setAttachment(map);

        request.setInterfaceName("com.cmb");
        String[] types = {"java.lang.Integer", "java.lang.String"};
        String[] params = {"java.lang.Integer", "java.lang.String"};
        request.setParameterTypes(types);
        request.setParameters(params);
        request.setMethodName("buy");
        request.setRequestId(123456);

        nettyMessage.setHeader(header);
        nettyMessage.setBody(request);

        return nettyMessage;
    }

}
